import 'package:car_map/mode/count_model.dart';
import 'package:car_map/mode/time_scale.dart';
import 'package:car_map/page/res/gaps.dart';
import 'package:car_map/widget/widget_license_time.dart';
import 'package:car_map/widget/widget_time_scale.dart';
import 'package:flutter/material.dart';

///里程统计
class MileageCountPage extends StatefulWidget {
  @override
  _mileageCountState createState() => _mileageCountState();
}

class _mileageCountState extends State<MileageCountPage> {
  List<TimeScale> timeList;
  CountModel countModel;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getTimeScaleList();
    getMileageCount();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text('里程统计'),
      ),
      body: ListView(
        children: <Widget>[
          TimeScaleWidget(
            timeScaleList: timeList,
          ),
          Gaps.vGap10,
          WidgetLicenseTime(countModel: countModel,)
        ],
      ),
    );
  }

  getTimeScaleList() {
    timeList = new List();
    timeList.add(new TimeScale(title: '今天', index: 0));
    timeList.add(new TimeScale(title: '三天', index: 1));
    timeList.add(new TimeScale(title: '近一周', index: 2));
    timeList.add(new TimeScale(title: '近一月', index: 3));
    timeList.add(new TimeScale(title: '本周', index: 4));
    timeList.add(new TimeScale(title: '本月', index: 5));
  }

  //获取车辆里程统计信息
  getMileageCount() {
    //时间
    List<CarInfoCount> timeDate = new List();
    timeDate.add(new CarInfoCount(timeDate: '10月1号'));
    timeDate.add(new CarInfoCount(timeDate: '10月2号'));
    timeDate.add(new CarInfoCount(timeDate: '10月3号'));
    timeDate.add(new CarInfoCount(timeDate: '10月4号'));
    timeDate.add(CarInfoCount(timeDate: '10月5号'));
    timeDate.add(CarInfoCount(timeDate: '10月6号'));
    timeDate.add(CarInfoCount(timeDate: '10月7号'));

    //油耗
    List<CarInfoCount> consumptiondata = new List();
    consumptiondata.add(new CarInfoCount(consumptionValue: 2.0));
    consumptiondata.add(new CarInfoCount(consumptionValue: 25.0));
    consumptiondata.add(new CarInfoCount(consumptionValue: 8.0));
    consumptiondata.add(new CarInfoCount(consumptionValue: 50.0));
    consumptiondata.add(new CarInfoCount(consumptionValue: 90.0));
    consumptiondata.add(new CarInfoCount(consumptionValue: 4.0));

    List<CarCountInfoEntityData> data = new List();
    data.add(
        new CarCountInfoEntityData(license: '陕AA0001', data: consumptiondata));
    data.add(
        new CarCountInfoEntityData(license: '陕AE0002', data: consumptiondata));
    data.add(
        new CarCountInfoEntityData(license: '陕AF0003', data: consumptiondata));
    data.add(
        new CarCountInfoEntityData(license: '陕AG0004', data: consumptiondata));
    data.add(
        new CarCountInfoEntityData(license: '陕AB0005', data: consumptiondata));
    data.add(
        new CarCountInfoEntityData(license: '陕AH0006', data: consumptiondata));

    countModel = new CountModel(timeDate: timeDate, data: data);
  }
}
